package org.viva.action.cms;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.viva.cms.sitemap.BaiduSm;
import org.viva.core.api.Ajax;
import org.viva.entity.cms.Movie;
import org.viva.secu.Security;
import org.viva.service.cms.MovieService;

@Controller
public class MovieAction {

    @Resource
    private MovieService movieService;

    @ResponseBody
    @RequestMapping(value = "/cms/content/save_movie", method = RequestMethod.POST)
    public Map<String, Object> doSave(Movie movie) {
        movie.setUserId(Security.getUser().getId());
        if (movie.getId() == null) {
            movieService.add(movie);
        } else {
            movieService.up(movie);
        }
        try {
            BaiduSm.art(movie.getId() + "");
        } catch (Exception e) {
        }
        return Ajax.exec(movie.getId());
    }

}
